package queue;

public class DequeTest {
    public static void main(String[] args) {
        Deque<Integer> deque = new ArrayDeque<>();
        //偶数从队尾加入；奇数从队首加入
        for (int i = 0; i < 16; i++) {
            if (i % 2 == 0) deque.addLast(i);
            else deque.addFront(i);
            System.out.println("deque = " + deque);
        }
        //之后，我们依次从队首和队尾轮流删除元素
        System.out.println();
        for (int i = 0; !deque.isEmpty(); i++) {
            if (i % 2 == 0) deque.removeFront();
            else deque.removeLast();
            System.out.println("deque = " + deque);
        }
    }

}
